package indi.zhifa.study2024.consigntest.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import indi.zhifa.core.common.web.entity.ann.ZhiFaRestController;
import indi.zhifa.core.common.web.entity.response.RestResponse;
import indi.zhifa.study2024.consigntest.logic.busy.consign.IConsignService;
import indi.zhifa.study2024.consigntest.logic.busy.consign.entity.mapperOut.ConsignMapperOut;
import indi.zhifa.study2024.consigntest.logic.busy.consign.entity.request.ConsignPageRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@Slf4j
@Validated
@RequiredArgsConstructor
@RequestMapping(value = "/api/test/class008/consign")
@ZhiFaRestController
@Tag(name = "销售单测试")
public class ConsignController {

    private final IConsignService mConsignService;

    @Operation(summary = "查询销售单报表-商品分组")
    @PostMapping(value = "/groupByItemId")
    public Page<ConsignMapperOut> pageGroupByItemId(@RequestBody ConsignPageRequest pConsignPageRequest){
        return mConsignService.pageGroupByItemId(pConsignPageRequest);
    }

    @Operation(summary = "初始化数据")
    @PostMapping(value = "/init")
    public RestResponse<String> initConsign(){
        mConsignService.initTestData();
        return RestResponse.ok("导入完成");
    }

    @Operation(summary = "同步新表")
    @PostMapping(value = "/syncNewTable")
    public RestResponse<String> syncNewTable(){
        mConsignService.syncNewTable();
        return RestResponse.ok("同步完成");
    }

}
